#!/usr/bin/perl -w

use Test::More tests => 5;
use File::Temp;

# =============================================================
# Cargamos el modulo
# ==============================================================
use_ok('Bench::Test::Local');

my $tempdir = File::Temp::tempdir( CLEANUP => 1 );

my $local = Bench::Test::Local->new (
   EXECUTABLE => 'echo',
   WORKDIR    => '.', 
   BASEDIR    => $tempdir,
);

isa_ok($local, 'Bench::Test::Local');

ok($local->execute_preamble, 'Executing preamble');

$local->save_result('Save this!', 'testname');

my $tempfile = "$tempdir/testname.base";

open FH, "< $tempfile"
   or die "An error ocurred when trying to open $tempfile";
my $output = <FH>;
close FH
   or die "An error ocurred when trying to close $tempfile";

is ($output, "Save this!\n", 'Saving result to base file');

ok($local->execute_postamble, 'Executing postamble');
